草庐IT

require 与 import

全部标签

python - pytorch如何设置.requires_grad False

我想卡住我的一些模型。按照官方文档:withtorch.no_grad():linear=nn.Linear(1,1)linear.eval()print(linear.weight.requires_grad)但它打印出True而不是False。如果我想将模型设置为评估模式,我应该怎么做? 最佳答案 requires_grad=假如果您想卡住模型的一部分并训练其余部分,您可以将要卡住的参数的requires_grad设置为False。例如,如果您只想保持VGG16的卷积部分固定:model=torchvision.models.v

python - 从 。导入_方法 ImportError : cannot import name '_methods' in cx-freeze python

exe使用cx-freeze成功构建。但是当我执行exe文件时它显示以下错误:from.import_methodsImportError:cannotimportname'_methods' 最佳答案 这个问题已经在这里回答:WhyamIgettingthisImportError?但为了完整起见,这里是针对这种特定情况的答案:cx_freeze未导入可选模块_method,因此您必须明确告诉他这样做。additional_mods=['numpy.core._methods','numpy.lib.format']setup(n

python - 从 。导入_方法 ImportError : cannot import name '_methods' in cx-freeze python

exe使用cx-freeze成功构建。但是当我执行exe文件时它显示以下错误:from.import_methodsImportError:cannotimportname'_methods' 最佳答案 这个问题已经在这里回答:WhyamIgettingthisImportError?但为了完整起见,这里是针对这种特定情况的答案:cx_freeze未导入可选模块_method,因此您必须明确告诉他这样做。additional_mods=['numpy.core._methods','numpy.lib.format']setup(n

python - pip "Could not find a version that satisfies the requirement pygame"

这个问题在这里已经有了答案:PygameinstallationforPython3.3(7个答案)关闭6年前。当我尝试安装PyGame时:pipinstallpygame它说CollectingpygameCouldnotfindaversionthatsatisfiestherequirementpygame(fromversions:)Nomatchingdistributionfound我相信我使用的是最新版本8.1.1。我在Windows8.1上使用Python3.5.1。我已经查看了此问题的其他答案,但没有一个对我有用。感谢您的帮助。

python - pip "Could not find a version that satisfies the requirement pygame"

这个问题在这里已经有了答案:PygameinstallationforPython3.3(7个答案)关闭6年前。当我尝试安装PyGame时:pipinstallpygame它说CollectingpygameCouldnotfindaversionthatsatisfiestherequirementpygame(fromversions:)Nomatchingdistributionfound我相信我使用的是最新版本8.1.1。我在Windows8.1上使用Python3.5.1。我已经查看了此问题的其他答案,但没有一个对我有用。感谢您的帮助。

python - 导入错误 : cannot import name '_ccallback_c'

最初我遇到这个错误(没有找到模块名称scipy)所以我安装了一个Scipywheel文件。现在我不再遇到同样的错误,但我得到了cannotimportname"_ccallback_c"。错误似乎是在第四行代码处触发的。我做了我的研究,看到其他人建议尝试像Anaconda这样的环境。我已经看到它在闲置时工作,并且该解决方案对我来说并不理想。回溯:Traceback(mostrecentcalllast):File"C:\Users\joesh\Desktop\Python\MachineLearning\1sttutorial.py",line4,infromsklearnimport

python - 导入错误 : cannot import name '_ccallback_c'

最初我遇到这个错误(没有找到模块名称scipy)所以我安装了一个Scipywheel文件。现在我不再遇到同样的错误,但我得到了cannotimportname"_ccallback_c"。错误似乎是在第四行代码处触发的。我做了我的研究,看到其他人建议尝试像Anaconda这样的环境。我已经看到它在闲置时工作,并且该解决方案对我来说并不理想。回溯:Traceback(mostrecentcalllast):File"C:\Users\joesh\Desktop\Python\MachineLearning\1sttutorial.py",line4,infromsklearnimport

python - : import scipy as sp/sc 的官方缩写

我都见过:importscipyassp和:importscipyassc是否在任何地方列出了官方偏好?例如,在IntroductionoftheScipydocumentation,建议importnumpyasnpimportmatplotlibasmplimportmatplotlib.pyplotasplt但是Scipy包没有提供类似的缩写。在thisquestion,建议使用sp,但Scipy文档的链接实际上并未指定sp而不是sc。 最佳答案 “官方”答案,根据Scipydocumentation,是真的没有理由永远imp

python - : import scipy as sp/sc 的官方缩写

我都见过:importscipyassp和:importscipyassc是否在任何地方列出了官方偏好?例如,在IntroductionoftheScipydocumentation,建议importnumpyasnpimportmatplotlibasmplimportmatplotlib.pyplotasplt但是Scipy包没有提供类似的缩写。在thisquestion,建议使用sp,但Scipy文档的链接实际上并未指定sp而不是sc。 最佳答案 “官方”答案,根据Scipydocumentation,是真的没有理由永远imp

python - INSTALLED_APPS 中的 Haystack 导致错误 : cannot import name openProc

我现在很困。我有一个Django项目,在我尝试添加Haystack/Whoosh进行搜索之前一直运行良好。我在其他项目中使用过相同的堆栈,效果很好。每当我的settings.INSTALLED_APPS中有“haystack”时,我都会尝试manage.pyrunserver或manage.pyshell我收到“错误:无法导入名称openProc”我认为这可能是Haystack的依赖项没有正确安装,所以我从站点包中删除Haystack并重新安装,但同样的事情不断发生。谷歌搜索openProc和相关关键字没有任何结果。我希望其他人遇到过这个错误,或者至少现在Google中会有一些可能有答